package com.huike.clues.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.core.page.TableDataInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {
    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;

    @Autowired
    private TbClueMapper tbClueMapper;

    @Override
    public boolean add(ClueTrackRecordVo tbClueTrackRecord,String username) {
        //添加记录表
        Integer add = tbClueTrackRecordMapper.add(tbClueTrackRecord, username);
        //更新clue表信息
        TbClue tbClue = new TbClue();
        Long clueId = tbClueTrackRecord.getClueId();
        tbClue.setStatus("2");
        tbClue.setId(clueId);
        BeanUtils.copyProperties(tbClueTrackRecord,tbClue);
        int i = tbClueMapper.updateTbClue(tbClue);
        return i!=0 && add!=0;
    }



    @Override
    public List<TbClueTrackRecord> getclue(Long clueId) {
        List<TbClueTrackRecord> getclue = tbClueTrackRecordMapper.getclue(clueId);
        return getclue;
    }
}
